package com.ls.datalog.service;

import java.math.BigDecimal;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ls.datalog.dao.ProductDao;
import com.ls.datalog.domain.Product;

@Service
public class ProductService {
	@Autowired
	private ProductDao dao;
	
	public void createProduct() {
		Product p = new Product();
		p.setBuyPrice(new BigDecimal(9.99));
		p.setSellPrice(new BigDecimal(10.22));
		p.setCategory("pc");
		p.setDetail("中关村地区");
		p.setName("联想笔记本");
		p.setProvider("lenovo");
		p.setOnlineTime(new Date());
		p.setUpdateTime(new Date());
		dao.save(p);
	}
	
	public void update(long id) {
		Product p = dao.getOne(id);
		p.setProvider("北京分公司");
		dao.save(p);
	}
	public void delete(long id ) {
		dao.delete(id);
	}
	
	public void delete2(long id) {
		dao.delete(dao.findById(id));
	}

}
